home *** CD-ROM | disk | FTP | other *** search
/ Georgia Wildfire Prevention / Georgia Wildfire Prevention.iso / mac / media / dirs / BackUp / Login.dir / 00006_Script_KeyPad Behavior < prev    next >
Text File  |  2002-10-11  |  3KB  |  90 lines

  1. --KeyPad Behavior--
  2. --This behavior operates the keypad.
  3. --PROPERTIES--
  4. --RollOvr: This is the member that will be used on a roll-over.
  5. --ButtonSound: The sound played when a button is pressed.
  6. --Keystroke: The keyboard key corresponding to the graphic. (i.e. A on the keyboard will activate the graphic key "A").
  7. --spNum: The sprite number.
  8. --MyNum: The member's number.
  9.  
  10. global HotField
  11. property RollOvr, ButtonSound, KeyStroke, spNum, MyNum,
  12.  
  13. on new me
  14.   spNum = me.spritenum
  15.   MyNum=sprite(SpNum).member.number
  16.   set TheKey = ""
  17. end
  18.  
  19. --Creates dialog box for properties.
  20. on getpropertydescriptionlist me
  21.   set pList = [#RollOvr: [#comment: "What member will be used for the rollover?", #format:#string, #default: ""],\
  22.   #ButtonSound: [#comment: "What sound would you like to play when pressed?", #format:#string, #default:""],\
  23.   #KeyStroke: [#comment:"What keyboard key does this button correspond to?", #format:#string, #default:""]]
  24.   return pList
  25. end
  26.  
  27. --If the user types with the keyboard, the corresponding key on the pad will go down (become transparent).
  28. on KeyBoardDown me,
  29.   set theKey = the keypressed
  30.   
  31.   if (theKey = numtochar (13)) or (theKey = numtochar (9)) then
  32.     theKey = "RETURN"
  33.   else if (theKey = numtochar (8)) or (theKey = numtochar(127)) then
  34.     theKey = "BACKSPACE"
  35.   end if
  36.   
  37.   if  theKey = keystroke  then
  38.     sound(2).play(member(ButtonSound))
  39.     sprite(spNum).blend = 0
  40.     updatestage
  41.     set TimeTracker = the ticks
  42.     repeat while the ticks < (TimeTracker + 5) then
  43.       nothing
  44.     end repeat
  45.     sprite(spNum).blend = 100
  46.   end if
  47. end
  48.  
  49. --This is for the rollover.
  50. on mouseenter me
  51.   sprite(SpNum).membernum = member(RollOvr).number
  52.   sprite(SpNum).cursor = 280  
  53.   updateStage  
  54. end
  55. on mouseleave me
  56.   sprite(SpNum).membernum = member(MyNum).number
  57.   sprite(SpNum).cursor = 293 
  58.   updateStage
  59. end
  60.  
  61. on mousedown me
  62.   if  KeyStroke = "RETURN" then--If the user presses RETURN (ENTER key on the PC) or TAB the next field goes active.
  63.     case (HotField) of
  64.       "First Name" : HotField = "Last Name"
  65.       "Last Name" : HotField = "Address"
  66.       "Address" : HotField = "City"
  67.       "City" : Hotfield = "State"
  68.       "State" : HotField = "Zip Code"
  69.       "Zip Code" : HotField = "Age"
  70.       "Age" : Hotfield = "First Name"
  71.     end case
  72.   end if
  73.   sprite(spNum).blend = 0
  74.   sound(2).play(member(ButtonSound))
  75.   sendallsprites (#FieldFiller, KeyStroke)
  76. end
  77. on mouseupoutside
  78.   sprite(spNum).blend = 100
  79. on mouseup
  80.   sprite(spNum).blend = 100
  81. end
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.